package initParam

import (
	"github.com/e421083458/golang_common/lib"
	"time"
)

var (
	// 全局变量
	CTarget              = "c_"                                                                        // 客户标志
	CsTarget             = "cs_"                                                                       // 客服标志
	RobotTarget          = "robot_"                                                                    // 机器人标志
	ChatMsgTxt           = "RC:TxtMsg"                                                                 // 显示类消息
	ChatMsgInfo          = "RC:InfoNtf"                                                                // 提示类消息
	ChatMsgSrs           = "RC:SRSMsg"                                                                 // 过滤类消息
	TimeFormatYear       = "2006-01-02 15:04:05"                                                       // 时间格式1
	TimeFormatYearDay    = "2006.01.02"                                                                // 时间格式2
	TimeFormatHourMinute = "15:04"                                                                     // 时间格式3
	CAvatar              = "https://oss.emakerzone.com/admin/img/1619333657046-1618476125364-创易栈1.png" // 客户默认头像
	FAEAvatar            = "https://oss.emakerzone.com/admin/img/1622101292602-FAE.png"                // 客服默认头像
	COnlineState         = 0                                                                           // 客户默认在线状态
	GZHTemplateId        = "K-iyKMvX3xhUDLkyf1QIbvaG4h7I6iqr5fpCEDlB-Ts"                               // 公众号推送模板
	InvitationTimeOut    = 5 * time.Minute                                                             // 邀请时间间隔
	TransferTimeOut      = 5 * time.Minute                                                             //
	DataIsNotExist       = "DATA IS NOT EXIST"                                                         //
	SendNoticeTimeOut    = 5 * time.Second                                                             //
	CsOnlineTimeOut      = 5 * time.Minute                                                             //
	// 中文变量
	ProductName           = "创易栈"                                 // 品牌名称1
	ProductNamePlatForm   = "创易栈平台"                               // 品牌名称2
	DealSuccessText       = "处理成功!"                               // 处理成功返回
	WeChatErrText40029    = "code 无效"                             // 微信报错1
	WeChatErrText45011    = "频率限制，每个用户每分钟100次"                    // 微信报错2
	WeChatErrText1        = "系统繁忙，此时请开发者稍候再试"                     // 微信报错3
	ErrorGroupMemberCache = "群成员 缓存数据 为空"                         // 报错1
	ErrorGroupCache       = "群 缓存数据 为空"                           // 报错3
	TimeBlockMsg          = "————————— 以上为历史消息 —————————"         // 时间断
	CsWelcomeMsg          = "云FAE管家实时在线，及时响应，精准匹配对应技能云FAE"        //客服在没有聊天的情况下，系统与客服发送的一个欢迎内容
	InvitationWaitMsg     = "正在为您邀请专家，一对一解决问题"                    //发起邀请时提示给到客户
	TransferWaitMsg       = "正在为您转接创易栈云FAE专家，请稍后"                 //发起转接时提示给到客户
	TimeoutText           = "超时未接"                                //
	ServiceText           = "为您服务"                                //
	AddText               = "加入会话"                                //
	QuiteText             = "已退出群聊"                               //
	MergeText             = "合并的聊天内容"                             //
	TransIsAcceptText     = "该转接已被接受"                             //
	TransIsRefuseText     = "该转接已被拒绝"                             //
	TransIsTimeoutText    = "该转接已超时"                              //
	TransRefuseText       = "拒绝了您的转接"                             //
	InvitationRefuseText  = "拒绝了您的邀请"                             //
	Customer              = "用户"                                  //
	TransMessageText      = "的转接待接收"                              //                                                             //
	InvitationMessageText = "邀您参与技术解答"                            //
	PublicHint            = "该用户还不是客服，但是登陆了客服端，这里给这个准客服创建一个群聊！！！" //
	UnreadMessageText     = "创易栈客服未读消息提醒"                         //
	UnreadCsHintText      = "收到用户新消息，请尽快处理"                       //
	UnreadCHintText       = "已经有客服回复了您的问题"                        //
	UnreadClickHintText   = "点击本消息立即查看"                           //
	// redis 前缀
	RobotPrefix              = "ovoRobot"           // ovoRobot
	KeyWordListPrefix        = "ovoKeyWordList"     // ovoKeyWordList
	ReplySettingPrefix       = "ovoReplySetting"    // ovoReplySetting
	OVOPrefix                = "ovo_"               // ovo_【$unionId】
	RCTokenPrefix            = "ovoRCToken_"        // ovoRCToken_【$uid】_【$isCustomerClient】
	ReportPrefix             = "ovoReport_"         // ovoReport_【$groupId】
	GroupPrefix              = "ovoGroup_"          // ovoGroup_【$groupId】
	GroupRobotPrefix         = "ovoGroupRobot_"     // ovoGroupRobot_【$groupId】
	GroupMemberPrefix        = "ovoGroupMember_"    // ovoGroupMember_【$groupId】
	GroupMemberCPrefix       = "ovoGroupMemberC_"   // ovoGroupMemberC_u_【$uid】_ou_【$uid2】
	GroupMemberCsPrefix      = "ovoGroupMemberCs_"  // ovoGroupMemberCs_u_【$uid】_ou_【$uid2】
	GroupMemberInGroupPrefix = "ovoMemberInGroup_"  // ovoMemberInGroup_u_【$uid】
	MessageListPrefix        = "ovoMessageList_"    // ovoMessageList_【$uid】
	MessagePrefix            = "ovoMessage_"        // ovoMessage_【$msgUid】
	ConfigPrefix             = "ovoConfig_"         // ovoConfig_【$key】
	UserPrefix               = "ovoUser_"           // ovoUser_【$uid】
	CsUserPrefix             = "ovoCsUser_"         // ovoCsUser_【$uid】
	CsUserGroupPrefix        = "ovoCsUserGroup_"    // ovoCsUserGroup_【$uid】
	CsUserListPrefix         = "ovoCsUserList_"     // ovoCsUserList_【$uid】【$accessType】
	CsUserRegisterPrefix     = "ovoCsUserRegister_" // ovoCsUserRegister_【$mobile】
	BrowseCurrentPrefix      = "ovoBrowseCurrent_"  // ovoBrowseCurrent_【$groupId】
	CsUserStatusPrefix       = "ovoCsUserStatus_"   // ovoCsUserStatus_【$uid】
	UrlLinkPrefix            = "ovoUrlLink_"        // ovoUrlLink_【$path】_【query】_【$isCustomerClient】
)

type Base struct {
	DebugMode    string
	TimeLocation string
	Host         string
}

var BaseConf Base

func GetBase() {
	conf := &BaseConf
	conf.DebugMode = lib.GetStringConf("base.base.debug_mode")
	conf.TimeLocation = lib.GetStringConf("base.base.time_location")
	conf.Host = lib.GetStringConf("base.base.host")
}

type Http struct {
	Addr           string
	ReadTimeout    int
	WriteTimeout   int
	MaxHeaderBytes int
	AllowIp        []string
}

var HttpConf Http

func GetHttp() {
	conf := &HttpConf
	conf.Addr = lib.GetStringConf("base.http.addr")
	conf.ReadTimeout = lib.GetIntConf("base.http.read_timeout")
	conf.WriteTimeout = lib.GetIntConf("base.http.write_timeout")
	conf.MaxHeaderBytes = lib.GetIntConf("base.http.max_header_bytes")
	conf.AllowIp = lib.GetStringSliceConf("base.http.allow_ip")
}

type Swagger struct {
	Title    string
	Desc     string
	Host     string
	BasePath string
}

var SwaggerConf Swagger

func GetSwagger() {
	conf := &SwaggerConf
	conf.Title = lib.GetStringConf("base.swagger.title")
	conf.Desc = lib.GetStringConf("base.swagger.desc")
	conf.Host = lib.GetStringConf("base.swagger.host")
	conf.BasePath = lib.GetStringConf("base.swagger.base_path")
}

type JwtSecret struct {
	Secret     string
	ExpireTime int
}

var JwtSecretConf JwtSecret

func GetJwtSecret() {
	conf := &JwtSecretConf
	conf.Secret = lib.GetStringConf("base.JwtSecret.secret")
	conf.ExpireTime = lib.GetIntConf("base.JwtSecret.expire_time")
}

type WeChatClient struct {
	AppId     string
	Secret    string
	GrantType string
}

var WeChatClientConf WeChatClient

func GetWeChatClient() {
	conf := &WeChatClientConf
	conf.AppId = lib.GetStringConf("base.wechat_client.appid")
	conf.Secret = lib.GetStringConf("base.wechat_client.secret")
	conf.GrantType = lib.GetStringConf("base.wechat_client.grantType")
}

type WeChatFAE struct {
	AppId     string
	Secret    string
	GrantType string
}

var WeChatFAEConf WeChatFAE

func GetWeChatFAE() {
	conf := &WeChatFAEConf
	conf.AppId = lib.GetStringConf("base.wechat_FAE.appid")
	conf.Secret = lib.GetStringConf("base.wechat_FAE.secret")
	conf.GrantType = lib.GetStringConf("base.wechat_FAE.grantType")
}

type RongCloud struct {
	Host      string
	AppKey    string
	AppSecret string
}

var RongCloudConf RongCloud

func GetRongCloud() {
	conf := &RongCloudConf
	conf.Host = lib.GetStringConf("base.rong_cloud.host")
	conf.AppKey = lib.GetStringConf("base.rong_cloud.appKey")
	conf.AppSecret = lib.GetStringConf("base.rong_cloud.appSecret")
}

type Redis struct {
	ProxyList []string
	Password  string
	DB        int
	MaxActive int
	MaxIdle   int
}

var RedisConf Redis

func GetRedis() {
	conf := &RedisConf
	conf.ProxyList = lib.GetStringSliceConf("base.redis.proxy_list")
	conf.Password = lib.GetStringConf("base.redis.password")
	conf.DB = lib.GetIntConf("base.redis.db")
	conf.MaxActive = lib.GetIntConf("base.redis.max_active")
	conf.MaxIdle = lib.GetIntConf("base.redis.max_idle")
}

func PutIntoMemory() {
	GetBase()
	GetHttp()
	GetSwagger()
	GetJwtSecret()
	GetWeChatClient()
	GetWeChatFAE()
	GetRongCloud()
	GetRedis()
}
